Nileo::Application.routes.draw do
  devise_for :users

  mount Ckeditor::Engine => '/ckeditor'

  namespace :documents do
    resources :publications, :except => :destroy
    resources :articles,     :except => :destroy
    resources :news,         :except => :destroy
    resources :conferences,  :except => :destroy do
      member do
        get 'join'
        delete 'leave'
        get 'members'
      end
      resources :reports, :except => [:index, :destroy]
    end
  end
  get 'tag/:label' => 'tag#index', :as => :list_documents_by_tag

  resources :comments, :only => [:new, :create, :destroy]

  put 'ratings/:target/:id/up'   => 'ratings#up',   :as => :rating_up
  put 'ratings/:target/:id/down' => 'ratings#down', :as => :rating_down

  namespace :admin do
    resources :users do
      post :roles, :on => :member
    end
    resources :mailing, :controller => 'mailing', :only => [:index, :show, :new, :create]
  end

  resources :terms, :path => 'dictionary' do
    collection do
      get 'start_with/:char', :action => :start_with, :as => :family #, :constraints => {:char => //}  # TODO
    end
  end

  root :to => 'home#index'
end
